package com.cjjd.c.feature.dialog;

import android.app.Dialog;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.cjjd.c.R;


/**
 * Created by dadagm on 17/9/11.
 */

public class TextDialog extends Dialog implements View.OnClickListener {

    private Context mContext;
    private OnCloseListener listener;
    private String message;
    private TextView tVmessage;
    private TextView tvTittle;
    private String title;

    public TextDialog(Context context, String message, OnCloseListener listener) {
        super(context, R.style.loading_dialog);

        setContentView(R.layout.dialog_text);

        this.mContext = context;
        this.listener = listener;
        this.message=message;
        initView();
    }

    public TextDialog(Context context, String title,String message, OnCloseListener listener) {
        super(context, R.style.loading_dialog);

        setContentView(R.layout.dialog_text);
        this.mContext = context;
        this.listener = listener;
        this.title = title;
        this.message=message;
        initView();
    }

    private void initView(){
        tVmessage=(TextView)findViewById(R.id.message);
        tvTittle=(TextView)findViewById(R.id.title);
        if (!TextUtils.isEmpty(title)){
            tvTittle.setText(title);
        }
        findViewById(R.id.ok).setOnClickListener(this);
        tVmessage.setText(message);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.ok:
                listener.OnClick();
                this.dismiss();
                break;
        }
    }

    public interface  OnCloseListener{

        public void OnClick();
    }
}
